package com.lzy.liujing.restaurant.dao;


import com.lzy.liujing.restaurant.entity.Member;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IDEA
 * author:LiuJing
 * Date:2018/10/1
 * Time:23:36
 */
@Mapper
public interface MemberDao{

    @Select("select * from r_member")
    List<Member> selectAll();

    @Select("<script> SELECT * from r_member" +
            "<where>"+
            "<if test='memberCode != null'>and member_code = #{memberCode}</if> "+
            " <if test='mname != null'>and m_name = #{mname}</if> "+
            " <if test='mcId != null'>and mc_id = #{mcId}</if> " +
            " <if test='mgender != null'>and m_gender = #{mgender}</if> " +
            "</where>"+
            "</script>")
    List<Member> findPage(Member query);

    @Delete("delete from r_member where member_id =#{memberId}")
    int delete(Integer id);
    @Insert("insert into r_member (member_code, m_name,m_gender,m_birthday, m_phone, mc_id, total_money) values " +
            " (#{memberCode},#{mname},#{mgender}, #{mbirthday}, #{mphone} " +
            " #{mcId}, #{totalMoney} )")
    int insert(Member brand);

    @Update("update r_member set member_code = #{memberCode}, m_name = #{mname}," +
            " m_gender = #{mgender}, m_birthday = #{mbirthday}, m_phone = #{mphone}, mc_id = #{mcId}," +
            " total_money = #{totalMoney}  where member_id = #{memberId}")
    int update(Member brand);

    @Select("SELECT * FROM r_member WHERE member_id = #{memberId}")
    Member getById(Integer id);
}
